#ifndef ONETCLIENT_H
#define ONETCLIENT_H

#include <QObject>
#include "connection.h"
#include "auth.h"

class OnetClient : public QObject
{
    Q_OBJECT
public:
    OnetClient(QObject* parent, const QString& aNick, const QString& aPassword);
    ~OnetClient();

    void processRaw(const QString& aCmd);

    bool isConnected()
    {
        return iConnection->IsConnected();
    }

private:
    // onet client username
    QString iNick;
    // onet client password
    QString iPassword;
    // nick auth?
    QString iNickAuth;

    Auth* iAuth;
    OnetConnection* iConnection;

    QStringList iCmdList;

public slots:
    void connectToHost();
    void disconnectHost();
    /*void sendToRoom(QString aRoom, QString aMessage);
    void sendToPriv(QString aPriv, QString aMessage);
    void joinRoom(QString aRoom);
    void leaveRoom(QString aRoom);
    void requestPriv(QString aUser);
    void acceptPriv(QString aUser);
    void rejectPriv(QString aUser);
    void ignorePriv(QString aUser);*/
    void sendRaw(QString aRaw);

private slots:
    void onSocketConnected();
    void onSocketDisconnected();
    void onReceived(QString aMessage);
    void onLog(QString aLog);
    void onError(int aError);

signals:
    void rawMessage(QString aMessage);
    void roomMessage(QString aRoom, QString aSender, QString aMessage);
    void privMessage(QString aSender, QString aMessage);
    void connected();
    void disconnected();
    void statusMessage(QString aStatus);
    void logMessage(QString aMessage);
    void activeMessage(QString aMessage);
    void registerUser(QString aRoom, QString aNick, QString aPrefix, QString aSuffix);

private:
    void rawPing();
    // :cf1f4.onet 001 scc_test :Welcome to the OnetCzat IRC Network scc_test!51976824@83.28.35.219
    void raw001();
    void raw801();
    void raw301();  // WHOIS away
    void raw302();  // WHOIS userhost 1
    void raw305();  // AWAY off
    void raw306();  // AWAY on
    void raw311();  // WHOIS base status
    void raw312();  // WHOIS online
    void raw314();  // WHOWAS ip
    void raw317();  // WHOIS times
    //---
    void raw319();  // WHOIS channels
    void raw353();  // NAMES
};

#endif // ONETCLIENT_H
